﻿#region

using Autofac;
using BTL.OnlineTestingSocial.Services.TestingEngine.Service.BLL;
using BTL.OnlineTestingSocial.Services.TestingEngine.Service.DAL;
using BTL.Technology.Data;
using BTL.Technology.Framework.Configuration;

#endregion

namespace BTL.OnlineTestingSocial.Services.TestingEngine.Service
{
    public class TestingEngineModule : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            var dbSetting = SectionConfiguration.GetInstance<DbSetting>(DbSetting.SectionName);

            // register db settings
            builder.RegisterInstance(dbSetting);

            // register data helper
            builder.RegisterType<DataHelper>().AsImplementedInterfaces();

            // register repositories
            builder.RegisterType<CategoryRepository>().AsImplementedInterfaces();
            builder.RegisterType<QuestionGroupRepository>().AsImplementedInterfaces();
            builder.RegisterType<CommentRepository>().AsImplementedInterfaces();
            builder.RegisterType<LikeRepository>().AsImplementedInterfaces();

            // register managers
            builder.RegisterType<CategoryManager>().AsImplementedInterfaces();
            builder.RegisterType<QuestionGroupManager>().AsImplementedInterfaces();
            builder.RegisterType<CommentManager>().AsImplementedInterfaces();
            builder.RegisterType<LikeManager>().AsImplementedInterfaces();

            // register services
            builder.RegisterType<TestingEngineService>().SingleInstance();
        }
    }
}